package com.sunxd.zstudy.java8.lambda;

import java.util.function.Consumer;

/**
 * @author sun.xd
 * @description: description
 * @date 2023/11/14 17:41
 */
public class TConsumer {
    public static void main(String[] args) {
        // 内部类的实现
        Consumer<String> consumer1 =  new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        consumer1.accept("abc");

        // lambda实现
        Consumer<String> consumer2 = x -> {
            System.out.println(x+x);
        };
        consumer2.accept("abc");

        Consumer<String> consumer3 = System.out::println;
        consumer3.accept("abc");
    }
}
